CC = gcc
CFLAGS = -Wall -O2
TARGET = menu
OBJS = menu.o music.o picture.o
INSTALL_DIR = /usr/bin

# 主目标
$(TARGET): $(OBJS)
	$(CC) $(CFLAGS) -o $@ $^

# 模块独立编译
menu.o: menu.c menu.h
	$(CC) $(CFLAGS) -c $< -o $@

music.o: music.c
	$(CC) $(CFLAGS) -c $< -o $@

picture.o: picture.c
	$(CC) $(CFLAGS) -c $< -o $@

# 安装到系统目录
install:
	cp $(TARGET) $(INSTALL_DIR)

# 卸载已安装文件
uninstall:
	rm -f $(INSTALL_DIR)/$(TARGET)

# 清理构建文件
clean:
	rm -f $(OBJS) $(TARGET)

.PHONY: install clean uninstall